// extractpdf.h
#ifndef EXTRACTPDF_H
#define EXTRACTPDF_H

#include <string>
#include <functional>
#include <map>
#include <vector>
#include <memory>
class CImageOutputDev;
#include <cpp/poppler-document.h>
#include <cpp/poppler-page.h>
using namespace poppler;

enum class ContentType
{
    content_text,
    content_img
};

typedef std::function<bool(int pageNumber, ContentType type, const char *content, const char *ext)> PageDataCallback;

class PdfExtractor
{
public:
    enum class ExtractionMode
    {
        TextOnly,
        ImagesOnly,
        TextAndImages
    };

    PdfExtractor();
    ~PdfExtractor();

    bool extractPdfTextAndImagesFromPage(int pageIdx, PageDataCallback callback, ExtractionMode mode, const std::string &outPath = "./out");
    bool setupFilePath(const std::string &pdfPath);
    int getPageCount() const;

    static bool extractAllPdfTextAndImages(const std::string &pdfPath, PageDataCallback callback, ExtractionMode mode, const std::string &outPath = "./out");

private:
    poppler::document *m_popplerDoc;
    CImageOutputDev *m_imgOut;
    int m_numPages;
};

#endif // EXTRACTPDF_H